package com.cskaoyan.javase.homework.day11;

/**
 * 读程序题
 * @since 09:32
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Test {
    public static void main(String[] args) {
        Father f1 = new Son(1000); // 0
        Father f2 = new Father(); // 10
        Son s = new Son(1000); // 0
        Student2 s2 = new Student2("str");
    }
}

class Father {
    int i = 10;

    public Father() {
        System.out.println(getI());
    }

    public int getI() {
        return i;
    }
}

class Son extends Father {
    int i = 100;

    public Son(int i) {
        // super();
        this.i = i;
    }
    @Override
    public int getI() {
        return i;
    }
}

class Student2 {
    int age;
    String name;
    int var;

    public Student2() {
    }

    public Student2(int age) {
        this.age = age;
    }

    public Student2(String name) {
        // 1.如果语法允许,没有意义.因为它只有默认值0,还不如直接写个0
        // 2.java中成员变量的赋值是先父后子的
        // Cannot reference 'Student.var' before supertype constructor has been called
        // this(var);
        this.name = name;
    }
}